package oj0405.oj0405_03;

import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static String zToh(String str){
        Stack<Character> stack = new Stack<>();
        stack.push('#');    //栈底先压入#
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (ch == '#') {
                break;
            }
            if (ch == '('){
                stack.push(ch);//左括号入栈
            }else if (ch == ')'){
                while (!stack.isEmpty() && stack.peek() != '('){
                    char pop = stack.pop();
                    sb.append(pop);
                }
                stack.pop();    //左括号出站
            }else if(Character.isDigit(ch)){
                sb.append(ch);
            }else {
                while (flag(ch) <= flag(stack.peek())){     //将当前字符和栈顶元素相比，符号等级更低就
                    char pop = stack.pop();
                    sb.append(pop);
                }
                stack.push(ch);
            }
        }
        while (stack.size() > 1){
            char pop = stack.pop();
            sb.append(pop);
        }
        return sb.toString();
    }
    public static int flag(char ch){
        if (ch == '+' || ch == '-') return 1;
        else if (ch == '/' || ch == '*' || ch == '%') return 2;
        else if (ch == '(') return 0;
        else return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        System.out.println(zToh(str));
        sc.close();
    }
}
